-- soul_to_item
-- created by chendh
-- 吸收生命精华转化为物品

return {
    apply = function(prop, baseValue)
        return prop[3];
    end,

    -- 吸取时触发触发
    trigger = function(who, prop, arg)

        if (who.dbase:query("vital_essence", 0) < prop[3]) then
            return false;
        end

        local classId = tonumber(prop[2]);

        -- 扣除生命精华
        who.dbase:set("vital_essence", who.dbase:query("vital_essence", 0) - prop[3]);

        -- 记录属性，增加下次的消耗
        PropM.record(who, {447, prop[2], 20, -1}, "soul");

        -- 奖励道具
        BonusM.doBonus({1, classId, 1}, "soul_to_item");

        EventMgr.fire(event.SOUL_COST, {["amount"] = prop[3], ["attrib"] = "vital_essence", ["bonus"] = {["classId"] = classId, ["amount"] = 1, } });

        -- 触发特技发动事件
        EventMgr.fire(event.SPECIAL_SKILL_TRIGGER, { propId = prop[1] });

        return true;
    end,

    record = function(target, prop, path)
        return false;
    end
};
